package com.iplant.wms.serviceImpl.thread;

import com.iplant.base.utils.cache.CacheUtils;
import com.iplant.base.utils.general.CalendarTool;
import com.iplant.base.utils.tasker.TaskTimerUtils;
import com.iplant.basic.service.po.bms.BMSEmployee;
import com.iplant.wms.service.po.mfs.*;
import com.iplant.wms.serviceImpl.utils.WMSAlarmUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class WMSThread implements DisposableBean {
    private static final Logger logger = LoggerFactory.getLogger(WMSThread.class);


    @PostConstruct
    public void init() {
        Run();
    }

    private void Run() {
        new Thread(() -> {
            try {
                Thread.sleep(5000);

                //调度任务
                TaskTimerUtils.AddTask(() -> {
                    WMSAlarmUtils.getInstance().WMS_StockAlarmCheckHR(BMSEmployee.SysAdmin);
                }, CalendarTool.getTime(6), CalendarTool.getTime(7), 2400000, -1);
            } catch (Exception ex) {
                logger.error("ApplicationThread", ex);
            }
        }).start();
    }

    @Override
    public void destroy() throws Exception {

        TaskTimerUtils.destroy();

    }
}
